<?php
namespace Common\Model;

use Think\Model;

class  SystemLogModel extends \BaseModel
{
    public function _initialize()
    {
        parent::_initialize();
    }

    public function load($id)
    {
        $data = $this->find($id);
        $type = $data['type'];
        hook("log_load", $data);
        hook("log_load_" . $type, $data);
        return $data;
    }


    public function add_log($row)
    {
        $row['add_date'] = date("Y-m-d H:i:s");
        $r = $this->add($row);
        return $r;
    }


    /*******生成对应的对应的日志表****/
    public function make_table($table_name)
    {
        $this->trueTableName = $table_name1 = "system_log$table_name";
        $sql = "CREATE TABLE `{$table_name1}` (
		  `id` int(11) NOT NULL AUTO_INCREMENT,
		  `remark` varchar(999) DEFAULT NULL,
		  `store_id` int(11) DEFAULT NULL,
		  `add_date` datetime DEFAULT NULL,
		  `num` decimal(11,2) DEFAULT '0.00',
		  `order_sn` varchar(225) DEFAULT '',
		  `user_id` int(11) DEFAULT '0',
		  `type` varchar(30) DEFAULT '',
		  PRIMARY KEY (`id`),
		  KEY `store_id` (`store_id`),
		  KEY `user_id` (`user_id`)
		) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        $bool = false;
        if (!in_array($table_name1, $this->tables)) {
            $this->query($sql);
            $bool = true;
        }
        if ($bool) {
            $this->resetTables();
        }
    }


}

?>